function y_hat = fast_interp( x, y, stateGrid_step, stateGrid,stateGrid_size)

dist = floor((x - stateGrid(1))/stateGrid_step);

ind_low  = 1 + floor((x - stateGrid(1))/stateGrid_step);
ind_high = ind_low + 1; 

ind_low( dist < 0) = 1; 
ind_high( dist < 0) = 2; 

ind_low( dist >=stateGrid_size-2) = stateGrid_size-1; 
ind_high( dist >=stateGrid_size-2) = stateGrid_size; 

%{
if dist < 0 
    ind_low = 1; 
    ind_high = 2; 
elseif dist >= stateGrid_size-2
    ind_low = stateGrid_size-1; 
    ind_high = stateGrid_size;
    
else
    
    ind_low  = 1 + floor((x - stateGrid(1))/stateGrid_step);
    ind_high = ind_low + 1; 
    
end
%}


w = (x - stateGrid(ind_low))/stateGrid_step; 

y_hat = (1-w).*y(ind_low) + w.*y(ind_high); 


end